package cn.lu.controller;

import cn.lu.pojo.User;
import cn.lu.utils.Result;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;


@Controller
@RequestMapping("/test")
@ResponseBody
public class TestController {

    @Autowired
    private JedisPool jedisPool;

    @RequestMapping(value = "/redis",method = RequestMethod.GET)
    public Result redisTest(){
        Jedis jedis = jedisPool.getResource();
        String s = jedis.get("41498313-651f-4c10-8575-81c0c78354c3");
        User user = (User) JSONObject.parseArray(s, User.class);
        return new Result().success(user);
    }

}
